package com.loveprogrammer.oss.common.uploader;

import com.aliyun.oss.OSSClient;

import java.io.File;

/**
 * 文件上传器
 *
 * @author 王旭
 * @version 1.0
 */
public class FileUploader extends AbstractUploader {
    // 文件
    private File file;

    public FileUploader() {
    }

    /**
     * @param file       文件
     * @param uploadPath 路径
     */
    public FileUploader(File file, String uploadPath) {
        super(uploadPath);
        this.file = file;
    }

    public FileUploader(File file, UploadPathBuilder uploadPathBuilder) {
        super(uploadPathBuilder);
        this.file = file;
    }

    /**
     * 上传文件
     *
     * @param ossClient  客户端
     * @param bucketName 储存名
     */
    @Override
    public void upload(OSSClient ossClient, String bucketName) {
        ossClient.putObject(bucketName, super.getUploadPath(), file);
    }

}
